package com.hsgene.user.controller.groundservant;

import com.hsgene.common.util.result.ApiResult;
import com.hsgene.common.util.support.LimitHelper;
import com.hsgene.user.condition.GroundServantCondition;
import com.hsgene.user.service.GroundServantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description: 地服信息controller
 * @ProjectName: hdas-geneshop
 * @Package: com.hsgene.user.controller.groundservant
 * @Author: 江承良
 * @CreateDate: 2018/10/18 17:49
 * @Version: 1.0
 * Copyright: Copyright (c) 2018
 */
@RestController
@RequestMapping("/v1.0/genetic/testing/groundServant")
public class GroundServantController {
    private Logger logger = LoggerFactory.getLogger(GroundServantController.class);
    @Resource
    private GroundServantService groundServantService;

    /***
     * 根据条件查询地服列表
     * @author jcl
     * @date 2018/10/19 11:17
     * @param groundServantCondition 查询条件
     * @param page 页码
     * @param size 大小
     * @return
     */
    @GetMapping("")
    public ApiResult groundServants(GroundServantCondition groundServantCondition,Integer page,Integer size){
        try {
            if(page==null||size==null){
                return new ApiResult(5001,"failed","分页条件不能为空",null);
            }
            LimitHelper limitHelper = LimitHelper.create(page, size, true);
            groundServantCondition.setLimitHelper(limitHelper);
            return groundServantService.groundServants(groundServantCondition);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("orders distribute page error",e);
            return new ApiResult(500,"failed","数据获取出错",e.toString());
        }
    }
}
